import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout'

export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/order',
    meta: {
      title: '首页',
      icon: 'home-4-line',
      affix: true,
    },
    children: [
      // {
      //   path: 'index',
      //   name: 'Index',
      //   component: () => import('@/views/index'),
      //   meta: {
      //     title: '优惠券发放',
      //     icon: 'home-4-line',
      //     affix: true,
      //   },
      // },
      {
        path: 'order',
        name: 'Order',
        component: () => import('@/views/order'),
        meta: {
          title: '订单',
          icon: 'lightbulb-flash-line',
          affix: true,
        },
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/user'),
        meta: {
          title: '用户',
          icon: 'user-5-line',
          affix: true,
        },
      },
      {
        path: 'report',
        name: 'Repoet',
        component: () => import('@/views/report'),
        meta: {
          title: '报表',
          icon: 'user-5-line',
          affix: true,
        },
      },
    ],
  },
]
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  ...asyncRoutes,
  {
    path: '/*',
    redirect: '/404',
    hidden: true,
  },
  // {
  //   path: '/403',
  //   name: '403',
  //   component: () => import('@/views/403'),
  //   hidden: true,
  // },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true,
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
})

export default router
